<template>
  <van-row class="recommend_item" type="flex" justify="space-between" align="center" gutter="4">
    <van-col span="24">
      <!--  层层嵌套   -->
      <van-row
        type="flex"
        justify="start"
        align="center"
        style="text-align: left"
        v-show="!(routeName === 'recommend_personDetail')"
      >
        <div style="display: flex;margin-bottom: 10px;">
          <van-image
            style="margin: 10px 10px 0 0;"
            round
            cover
            @click="singlar(item)"
            width="1.3rem"
            height="1.3rem"
            :src="item.avatar ? item.avatar : logoImg"
          />
          <div style="width: 240px;font-weight: 600;color: #828282;">
            <div style="margin-top: 10px">{{ '近聘昵称：' + (item.nick_name ? item.nick_name : '暂无') }}</div>
            <div style="margin-top: 10px">{{ '近聘账号：' + (item.ids ? item.ids : '暂无') }}</div>
            <div style="display: flex; justify-content: space-between">
              <div
                style="margin-top: 10px;"
              >{{ '手机号：' + (item.mobile ? $hidePhone(item.mobile) : '暂无') }}</div>

              <van-button
                size="mini"
                type="info"
                plain
                round
                @click.stop="call(item.mobile)"
                style="padding: 0 8px;flex-shrink: 0;"
              >电话联系</van-button>
            </div>
          </div>
        </div>
      </van-row>
      <van-row type="flex" justify="start" align="center" style="text-align: left">
        <van-col span="12">
          <div>
            工作状态：
            <van-tag :type="needStatus">{{ item.job_status ? statusName[item.job_status] : '未知' }}</van-tag>
          </div>

          <div style="margin-top: 10px">{{ '工作时长：' + (item.jobtime ? item.jobtime : '暂无') }}</div>
          <div
            style="margin-top: 10px"
          >{{ '工作类型：' + (item.job_category_id ? showLx(item.job_category_id) : '暂无') }}</div>
          <!-- <div
            style="margin-top: 10px"
          >{{ '上家服务费：' + (item.last_cost ? '￥' + item.last_cost : '暂无') }}</div>-->
          <div
            style="margin-top: 10px"
          >{{ '平台服务费：' + (item.platform_cost ? '￥' + item.platform_cost : '暂无') }}</div>

          <div
            style="margin-top: 10px"
          >{{ '代招类型：' + (item.generation_of_commission ? item.generation_of_commission : '暂无') }}</div>
          <div
            style="margin-top: 13px"
          >{{ '代招费：' + (item.dzftotalmny ? '￥' + item.dzftotalmny : '暂无') }}</div>
          <div
            style="margin-top: 10px"
          >{{ '代招费到账：' + (item.accounting_cost ? '￥' + item.accounting_cost : '暂无') }}</div>

          <div
            style="margin-top: 10px"
          >{{ '注册来源名称：' + (item.sourcename ? item.sourcename : '未知') }}</div>

          <div
            style="margin-top: 10px"
          >{{ '注册来源类型：' + (item.sourcetype ? sourceTypeObj[item.sourcetype] : '未知') }}</div>
          <!-- <div
            style="margin-top: 10px"
          >{{ '下家服务费：' + (item.former_service_fee ? '￥' + item.former_service_fee : '暂无') }}</div>-->
          <!-- <div
            style="margin-top: 10px"
          >{{ '下家服务费到账：' + (item.former_service_fee ? '￥' + item.former_service_fee : '暂无') }}</div>-->
          <div
            style="margin-top: 10px"
            v-if="item.company_id"
          >{{ '企业提成到账：' + (item.arrivemny ? '￥' + item.arrivemny : '暂无') }}</div>
        </van-col>
      </van-row>

      <van-row
        v-if="item.company_id"
        type="flex"
        justify="start"
        align="center"
        style="text-align: left; margin-top: 10px;"
      >
        <van-col span="12">
          <div>企业提成：{{ item.totalmny ? item.totalmny : '暂无' }}</div>
        </van-col>
        <van-col span="12">
          <div>
            <span>企业资料：</span>
            <van-tag
              type="primary"
              size="medium"
              @click.stop="toEnterpriseDetailPage(item.company_id)"
            >点击查看</van-tag>
          </div>
        </van-col>
      </van-row>


      <div style="margin-top: 10px; text-align: left;">
        <span>{{ '注册时间：' + (item.registertime ? item.registertime : '未知') }}</span>
        <van-tag
          plain
          size="medium"
          type="primary"
          @click="handleClick(item)"
          style="margin-left: 20px;"
          v-show="!(routeName === 'recommend_personDetail')"
        >结算记录</van-tag>
      </div>
      <div style="margin-top: 10px; text-align: left"
           v-show="$route.path.indexOf('recommend_person_Detail') > -1"
      >{{ '结算时间：' + (item.by_time ? item.by_time : '暂无') }}</div>

      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left;"
        v-show="(routeName === 'recommendPersons')"
      >
        <van-col span="6"><span >他推广的用户：</span></van-col>
        <van-col span="10">
          <div>个人用户：<span style="font-weight: bolder; color: red; font-size: 13px">{{ item.personcount || '0'}}</span></div>
          <div style="margin-top: 6px;">企业用户：<span style="font-weight: bolder; color: #F70000; font-size: 13px; margin-top: 6px;">{{item.companycount || '0'}}</span></div>
        </van-col>
        <van-col span="4">
          <van-tag
            size="medium"
            type="primary"
            @click="toViewDownstreamUsers(item, 'RP')"
          >查看</van-tag>
        </van-col>
      </van-row>

      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left; vertical-align: center"
        v-show="(routeName === 'recommendPersons') && item.company_id"
      >
        <van-col span="24">
          <span>一级推广用户发布招聘信息的总数：</span>
          <span style="font-weight: bolder; color: blue; font-size: 13px; margin-right: 20px">{{ item.jobcount || '0'}}</span>
          <van-tag
            size="medium"
            color="#A701F0"
            @click="toCompanyPage(item.company_id)"
          >前往查看</van-tag>
        </van-col>
      </van-row>
      

      <!-- <van-row
        type="flex"
        style="margin-top: 10px; text-align: left; vertical-align: center"
        v-show="(routeName === 'recommendPersons') && item.company_id"
      >
        <van-col span="24">
          <span>二级推广用户发布招聘信息的总数：</span>
          <span style="font-weight: bolder; color: blue; font-size: 13px; margin-right: 20px">{{ '007' || '0'}}</span>
          <van-tag
            size="medium"
            color="#0075FF"
            @click="toViewDownstreamUsers(item, 'L2Job')"
          >查看</van-tag>
        </van-col>
      </van-row> -->

      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left; vertical-align: center"
      >
        <van-col span="24">
          <span>二级推广用户发布招聘信息的总数：</span>
          <span style="font-weight: bolder; color: blue; font-size: 13px; margin-right: 20px">{{ '007' || '0'}}</span>
          <van-tag
            size="medium"
            color="#0075FF"
            @click="toViewDownstreamUsers(item, 'L2Job')"
          >查看</van-tag>
        </van-col>
      </van-row>

      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left;"
        v-show="(routeName === 'recommendPersons')"
      >
        <van-col span="8"><span >我获得的一级股份：</span></van-col>
        <van-col span="10">
          <div>已领取：<span style="font-weight: bolder; color: red; font-size: 13px">{{ item.personcount || '0'}}</span></div>
          <div style="margin-top: 6px;">未领取：<span style="font-weight: bolder; color: #F70000; font-size: 13px; margin-top: 6px;">{{item.companycount || '0'}}</span></div>
        </van-col>
        <van-col span="6">
          <van-tag
            size="medium"
            type="primary"
            @click="toRelatedStockInfo(item, 'L1')"
          >查看详情</van-tag>
        </van-col>
      </van-row>

      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left;"
        v-show="(routeName === 'recommendPersons')"
      >
        <van-col span="8"><span>我获得的二级股份：</span></van-col>
        <van-col span="10">
          <div>已领取：<span style="font-weight: bolder; color: red; font-size: 13px">{{ item.personcount || '0'}}</span></div>
          <div style="margin-top: 6px;">未领取：<span style="font-weight: bolder; color: #F70000; font-size: 13px; margin-top: 6px;">{{item.companycount || '0'}}</span></div>
        </van-col>
        <van-col span="6">
          <van-tag
            size="medium"
            type="primary"
            @click="toViewDownstreamUsers(item, 'L2')"
          >查看详情</van-tag>
        </van-col>
      </van-row>

      <div style="margin-top: 12px; text-align: left; display: flex; align-items: center;">
        <span>一级服务追踪备注：</span>
        <textarea style="width: 180px; height: 50px" />
        <van-tag plain style="margin-left: 8px; padding: 5px;" type="primary" @click="toSubmitNote(item)" >提交</van-tag>
      </div>


      <!--  下游的申请股份数    -->
<!--      <van-row
        type="flex"
        style="margin-top: 10px; text-align: left;"
        v-show="(routeName === 'recommendPersons')"
      >
        <van-col span="9">
          <span>他申请了
            <span style="font-size: 15px; font-weight: bolder; margin: 0 1px; color: red;">{{'22'}}</span>
            种股份：
          </span>

        </van-col>
        <van-col span="9">
          <div>理想的总价格：<span style="font-weight: bolder; color: red; font-size: 13px; margin-right: 3px">{{ item.idealPrice || '0'}}</span>元</div>
          <div style="margin-top: 6px;">审核的总股份：
            <span style="font-weight: bolder; color: #F70000; font-size: 13px; margin-top: 6px; margin-right: 3px">
              {{item.allStock || '0'}}
            </span>股
          </div>
        </van-col>
        <van-col span="4">
          <van-tag
            size="medium"
            type="primary"
          >查看</van-tag>
        </van-col>
      </van-row>

      &lt;!&ndash;  未申请次数    &ndash;&gt;
      <van-row type="flex" justify="start" align="center" style="text-align: left" v-show="(routeName === 'recommendPersons')" >
        <van-col span="12">
          <div>
            他发布的招聘信息个数：<span style="font-size: 16px; font-weight: bolder; margin: 0 1px; color: #FF976A;" >8</span><span style="margin-left: 6px;">次</span>
          </div>
        </van-col>
      </van-row>-->


    </van-col>
  </van-row>
</template>

<script>
import logoImg from '@/assets/logo.png'
import {Toast} from "vant";
export default {
  name: 'comRecommendItem',
  props: {
    item: Object,
    routeName: String
  },
  data() {
    return {
      logoImg,
      sms: '',
      statusName: {
        Leave: '自离',
        Resign: '辞职',
        OnJob: '在职'
      },
      sourceTypeObj: {
        'L': '网址链接',
        'V': '竖版海报',
        'H': '横版海报',
      },
    }
  },

  computed: {
    needStatus() {
      switch (this.item.work_status) {
        case '在职':
          return 'success'
        case '离职':
          return 'danger'
        default:
          return 'warning'
      }
    }
  },
  created() {
    // console.log('item')
    // console.log(this.item)
    // console.log('item')
  },
  methods: {
    // 头像查询资料跳转即时通讯
    singlar(val){
      console.log(val)
      this.$router.push(
        { name: 'headDetail', params: { SendUserId: val.id,MessagePage:'popularize' }}
      )
    },
    toSubmitNote(item){
      console.log('item', item);
    },

    handleClick(item) {
      if (this.routeName != 'recommend_personDetail') {
        this.$router.push({
          path: `/recommend_person_Detail/${item.id}`
        })
      }
    },
    showLx(id) {
      //1 全职 2 兼职 3 小时工
      switch (id) {
        case '1':
          return '全职'
        case '2':
          return '兼职'
        case '3':
          return '小时工'
      }
    },
    toEnterpriseDetailPage(id) {
      console.log('点击对象的id', id)
      this.$router.push({
        path: `/enterpriseDetail/${id}`
      })
      // todo 以后使用
      /*if(id && this.item.isEnterpriseUser){
          this.$router.push({
            path: `/enterpriseDetail/${id}`
          })
        } else {
          Dialog.alert({
            title: '抱歉！',
            message: '您不是企业用户，无法查看。',
            theme: 'round-button',
            messageAlign: 'left',
          }).then(() => {
            // on close
          });
        }*/
    },
    call(mobile) {
      if (mobile) window.location.href = 'tel:' + mobile
    },
    toViewDownstreamUsers(item, keyword) {
      if (this.routeName === 'recommendPersons') {
        this.$router.push({
          name: `downstreamUsers`,
          query: {
            id: item.id,
            avatar: item.avatar,
            nick_name: item.nick_name,
            mobile: item.mobile,
            ids: item.ids,
            registertime: item.registertime,
            company_id: item.company_id,
            personcount: item.personcount,
            companycount: item.companycount,
            jobcount: item.jobcount,
            keywordId: keyword
          }
        })
      }
    },

    toRelatedStockInfo(item = {}, levelNo){
      console.log('levelNo', item, levelNo);
      if(levelNo === 'L1'){
        this.$parent.showAction = true;
      }
    },


    toCompanyPage(id) {
      if(id){
        this.$router.push({
          path: `/company/${id}`
        })
      } else{
        Toast.fail('请稍等，正在获取数据！');
      }
    },
  }
}
</script>

<style scoped lang="css">
.recommend_item {
  box-sizing: border-box;
  border-bottom: 1px solid #eee;
  line-height: 1.1em;
  padding: 16px 0 16px 16px;
  position: relative;
}
</style>
